﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Utilities;

namespace ManageTicket.Partner
{
    public partial class frmSearchProvider : Form
    {
        #region Contructor
        public frmSearchProvider()
        {
            InitializeComponent();
        }
        #endregion

        #region Variable
        clsMethod4All objMethod = new clsMethod4All();
        ManageTicket.Library.Common.CommonFunction clsCommonFunc = new ManageTicket.Library.Common.CommonFunction();
        public ArrayList arrResult;
        #endregion

        #region Event
        private void frmSearchProvider_Load(object sender, EventArgs e)
        {
            arrResult = new ArrayList();
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            Business.Provider boProvider = new Business.Provider();

            object[] oParam = new object[5];
            oParam[0] = txtProviderId.Text;                                     //Provider_Id
            oParam[1] = txtProviderName.Text;                                   //Provider_Name
            oParam[2] = txtPersonRepresent.Text;                                //Person_Represent
            oParam[3] = txtPersonContact.Text;                                  //Person_Contact
            oParam[4] = "CUR";                                                  //Status

            //goi ham search
            ArrayList arr = new ArrayList();
            arr = boProvider.SearchProvider(oParam);

            //danh sach tra ve
            lvwProvider.Items.Clear();
            ListViewItem item;
            foreach (DataObjects.Provider oPro in arr)
            {
                item = new ListViewItem();
                item.Text = oPro.ProviderId;
                item.SubItems.Add(oPro.ProviderName);
                item.SubItems.Add(oPro.PersonRepresent);
                item.SubItems.Add(oPro.PersonContact);

                lvwProvider.Items.Add(item);
            }
            lblCount.Text = "Tổng: " + lvwProvider.Items.Count.ToString();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            arrResult = new ArrayList();
            DataObjects.Provider oPro;
            foreach (ListViewItem item in lvwProvider.CheckedItems)
            {
                oPro = new DataObjects.Provider();
                oPro.ProviderId = item.Text;
                oPro.ProviderName = item.SubItems[1].Text;

                arrResult.Add(oPro);
            }
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            arrResult = new ArrayList();
            this.Close();
        }

        private void chkAll_CheckedChanged(object sender, EventArgs e)
        {
            foreach (ListViewItem item in lvwProvider.Items)
            {
                item.Checked = chkAll.Checked;
            }
        }
        #endregion

        #region Execute
        #endregion

        #region Method
        #endregion
        

        
    }
}
